package com.lagou.frame;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;

import javax.servlet.ServletException;

/**
 * @ClassName SpringApplication
 * @Description TODO
 * @Auth ying.xiao
 * @Date 2021/3/3
 * @Version 1.0.0
 */
public class SpringApplication {

	public static void run(){
		//创建tomcat实例
		Tomcat tomcat = new Tomcat();
		//设置tomcat端口
		tomcat.setPort(8080);
		try {
			//此处随便指定一下webapp，让tomcat知道这是一个web工程
			tomcat.addWebapp("/springboot", "D:\\");
			//启动tomcat
			tomcat.start();
			tomcat.getServer().await();
		} catch (LifecycleException e) {
			e.printStackTrace();
		} catch (ServletException e) {
			e.printStackTrace();
		}
	}
}
